<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>青鸟影院管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/layui.css" media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/common.css">
    <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
    <script type="text/javascript">
    
    var cc = 0;
    ajaxCount();
    
    
    function ajaxCount() {
        $.ajax({
            url : "/SSM_CMS/countpuser.do",
           type : "get",
           success : function (m) {
              arry = JSON.parse(m);
              cc = arry["counts"];
              
             }
        });
    }
    
    </script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo"><span>青鸟影院管理系统</span></div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="updateAdmin.html" >
                     <img src="${pageContext.request.contextPath}/img/default.png" class="layui-nav-img layui-anim layui-anim-rotate"/>
                     <span id="user_name"></span>
                </a>
            </li>
              <li class="layui-nav-item"><a href="adminNo">退出</a></li>
        </ul>
    </div>
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test" id="leftside">
                    <script id="side" type="text/html">
                        {{#  layui.each(d.list, function(index, item){ }}
                        <li class="layui-nav-item">
                            <a href="{{item.url}}"><i class="layui-icon {{item.icon}}"></i> {{item.name}}</a>
                        </li>
                        {{#  }); }}
                        {{#  if(d.list.length === 0){ }}
                        无数据
                        {{#  } }}
                    </script>
                </ul>
            </div>
        </div>
        <div class="layui-body">
            <!-- 主体区域开始 -->
            <!--当前位置开始-->
            <div class="layui-card layadmin-header">
                <span class="layui-breadcrumb">
                      <a href="index.html">系统</a>
                      <a><cite>订单处理</cite></a>
                </span>
            </div>
            <!--当前位置结束-->
            <div class="layui-row">
                <div id="system" style="height: 400px">
                    <div class="head">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <div class="layui-input-inline" style="width: 200px;">
                                        <input type="text" id="names" lay-verify="required" placeholder="请输入影厅或影片或用户名" lay-verType="tips" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <button class="layui-btn layui-btn-radius" id="btns">
                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
                                    </button>
                                </div>
                            </div>
                    </div>
                    
                    <table class="layui-table">
                        <thead>
                            <tr>
                                <td>序号</td>
                                <td>用户</td>
                                <td>影片</td>
                                <td>影厅</td>
                                <td>座位</td>
                                <td>放映时间</td>
                                <td>价格</td>
                                <td>操作</td>
                            </tr>
                        </thead>
                        <tbody id="td">
                            <c:forEach items="${orderds}" var="orderd" varStatus="status">
                                <tr>
                                    <td>${orderd.orderId}</td>
                                    <td>${orderd.memberName}</td>
                                    <td>${orderd.movie.movieName}</td>
                                    <td>${orderd.hall.hallName}</td>
                                    <td>${orderd.setRow}排${orderd.setColumn}座</td>
                                    <td><fmt:formatDate value="${orderd.schedule.beginDate}" pattern="yyyy-MM-dd"/> ${orderd.schedule.beginHour}：<c:if test="${orderd.schedule.beginMinute<10}">0</c:if>${orderd.schedule.beginMinute}</td>
                                    <td>${orderd.schedule.moviePrise}</td>
                                    <td>
                                        <c:choose>
                                            <c:when test="${orderd.orderReturn==1}">
                                                <a class="layui-btn layui-btn-xs" style="width: 52px;cursor: default">已退票</a>
                                            </c:when>
                                            <c:otherwise>
                                                <a name="ReturnTicket" myid="${orderd.orderId}" class="layui-btn layui-btn-xs" style="width: 52px"><i class="layui-icon layui-icon-edit"></i>退票</a>
                                            </c:otherwise>
                                        </c:choose>
                                        </td>
                                </tr>
                            </c:forEach>
                        </tbody>
                    </table>
                    <!-- 页码128 -->
                    <div id="yeNum">
                        <div id="page"></div>
                    </div>
                </div>
            </div>
            <!--主体区域结束-->
        </div>
      <div class="layui-footer" style="text-align:center">
        <!-- 底部固定区域 -->
        © 版权管理
    </div>
    </div>
    <script src="${pageContext.request.contextPath}/js/layui.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.js"></script>
    <script src="${pageContext.request.contextPath}/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery.cookie.js"></script>
    
    <script type="text/javascript">

        $("a[name='ReturnTicket']").click(function () {
            var self = this;
            var orderId = $(self).attr("myid");
            $.ajax({
                data:{"orderId":orderId},
                dataType:"text",
                type:"post",
                url:"ReturnTicket",
                traditional: true,
                success: function () {

                    $(self).replaceWith('<a class="layui-btn layui-btn-xs" style="width: 52px;cursor: default">已退票</a>');
                },

            });
        });

        $("a[id='checkIdArray']").click(function () {
            if($("input[name='checkId']:checkbox:checked").length>0){
            var checkId = [];
            $("input[name='checkId']:checkbox:checked").each(function (i) {
                checkId[i]=$(this).val();
                console.log(checkId[i]);
            });

            $.ajax({
                data: {"checkId":checkId},
                dataType:"text",
                type:"post",
                url:"DeleteOrder",
                traditional: true,
                success:function (data) {
                },

            });

                location.reload();
            }
        });
    
    function linklist(arry) {
        var num = 1;
        for(var i in arry){
            str +="<tr>";
            str +="<td>"+(num++)+"</td>";
            str +="<td>"+arry[i]["names"]+"</td>";
            str +="<td>"+arry[i]["sex"]+"</td>";
            str +="<td>"+arry[i]["iphone"]+"</td>";
            str +="<td>"+arry[i]["email"]+"</td>";
            str +="<td><img src='${pageContext.request.contextPath}/img/abc.jpg' class='userhead'></td>";
            if(arry[i]["states"]=='正常'){
                str +="<td><span class='layui-badge layui-bg-green'>"+arry[i]["states"]+"</span></td>";
            }else{
                str +="<td><span class='layui-badge layui-bg-red'>"+arry[i]["states"]+"</span></td>";
            }
            str +="<td> <a href='OrderUpdate?id="+arry[i]["id"]+"' class='layui-btn layui-btn-xs'><i class='layui-icon layui-icon-edit'></i>修改</a>";
            str +="<a class='layui-btn layui-btn-danger layui-btn-xs delpuser' rel='"+arry[i]["id"]+"'><i class='layui-icon layui-icon-delete'></i>删除</a>";
        }
    }
    
    function del_puser() {
        $(".delpuser").click(function(){
            var ids = $(this).attr("rel");
            layer.open({
                icon:3,
                content:"确认删除 ID 为："+$(this).attr("rel")+" 的信息吗？",
                title:"确认删除",
                btn: ['确定', '取消'],
                yes: function(index, layero){
                    $.ajax({
                     url : "/SSM_CMS/delPUser.do",
                     type : "post",
                     data:{
                         "result" : ids,
                     },
                     success : function (m) {
                         var arry = JSON.parse(m);
                         console.log(arry);
                         if(arry.state==1){
                            layer.msg("删除成功",{
                                icon:1,time:2000
                            });
                             setTimeout("location.href='users.html'",1000);
                         }else{
                             layer.msg('删除失败', {icon: 5,time: 800});
                         }
                     }
                });
                    
                }
                ,btn2: function(index, layero){
                    layer.msg("已取消",{
                        icon:2,time:1000
                    });
                }
            });
            return false;
        });
    }
    
    
    $('#btns').click(function () {
        var names = $('#names').val();
        if(names.trim().length==0){
            location.href="Order";
        }else{
            location.href="likeOrder?val="+names;
        }
        
    });
    </script>
    
</body>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/page.js"></script>
<script type="text/javascript">

    //页数pageTotal代表总页数,curPage当前页数,paginationId加载页面的id,shou首页,wei尾页,shan上一页,xia下一页,sznum数字跳转
    var num =${pages.pages};//'总页数';
    var page =${pages.pageNum};// '当前页数';
    var shous ="Order" ;//'超链接首页'
    var weis ="Order?pageNum=${pages.pages}" ;//'超链接尾页'
    if (${pages.hasPreviousPage}){
        var shans ="Order?pageNum=${pages.pageNum-1}"; //'超链接上一页'
    }else{
        var shans ="Order"; //'超链接上一页'
    }
    if (${pages.hasNextPage}){
        var xias = "Order?pageNum=${pages.pageNum+1}";//'超链接下一页'
    }else{
        var xias ="Order?pageNum=${pages.pages}"; //'超链接下一页'
    }
    var pages={pageTotal:num,curPage:page,paginationId:"",shou:shous,wei:weis,shan:shans,xia:xias,sznum:"Order?pageNum="};
//调用page.js里的方法
    dynamicPagingFunc(pages);
</script>
</html>
